<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<link type="text/css" rel="stylesheet" href="css/validator.css"></link>
<script type="text/javascript" src="js/formValidator.js"></script>
<script type="text/javascript" src="js/formValidatorRegex.js"></script>
<script type="text/javascript">
$(document).ready(
	// function(){
	// 	$.formValidator.initConfig({formID:"myForm",onError:function(msg){return false;},onSuccess:function(){return true;}});
	// 	$("#email").formValidator({onShow:"请输入邮箱",onFocus:"请输入邮箱",onCDorrect:" "}).inputValidator({min:6,max:25,onerror:"邮箱在6到25字之间,请确认"}).regexValidator({regExp:"email",dataType:"enum",onError:"你输入的邮箱格式不正确"})
	//     .ajaxValidator({
	// 	    type : "get",
	// 		url : "register.php?action=email",
	// 		datatype : "json",
	// 		success : function(data){	
	//             if( data == "1" ){
	// 				return true;
	// 			}else{
	// 				return false;
	// 			}
	// 		},
	// 		error: function(){alert("服务器没有返回数据，可能服务器忙，请重试");},
	// 		onerror : "邮箱已被注册，请重新输入",
	// 		onwait : "正在对邮箱进行合法性校验，请稍候..."
	// 	});
	// 	$("#name").formValidator({onShow:"请输入用户名",onFocus:"请输入用户名",onCDorrect:" "}).inputValidator({min:1,max:20,empty:{leftEmpty:false,rightEmpty:false,emptyError:"用户名两边不能有空符号"},onerror:"用户名在1到20字之间,请确认"})
	// 	$("#pwd").formValidator({onShow:"请输入密码",onFocus:"请输入密码",onCDorrect:" "}).inputValidator({min:1,max:20,empty:{leftEmpty:false,rightEmpty:false,emptyError:"密码两边不能有空符号"},onerror:"密码在1到20字之间,请确认"})
	// 	$("#pwd2").formValidator({forcevalid:true,triggerevent:"change",onshow:"请输入重复密码",onfocus:"两次密码必须一致",oncorrect:" "}).compareValidator({desID:"pwd",operateor:"=",onError:"两次密码不一致,请确认"});
	// 	$("input:[name=sex]").formValidator({tipID:"sexTip",onShow:"请选择你的性别",onFocus:"请选择你的性别",onCorrect:"选择正确"}).inputValidator({min:1,max:1,onError:"没有选择性别,请确认"});
	// 	$("#city").formValidator({onShow:"请选择所在城市",onFocus:"请选择所在城市",onCorrect:"选择正确"}).inputValidator({min:1,onError: "请选择所在城市"});
	// }
)

$(function(){
	 $("input[name='email']").blur(function(){
        var data=$(this).val();
        var pattern_email = /^\w+@[a-z0-9\-]+\.[a-z]+(\.[a-z]+)?$/i;
        var pattern_phone = /^((13[0-9])|(15[0-9])|147|(18[0-35-9]))\d{8}$/;
        if(pattern_email.test(data)){
        	alert('这是邮箱号！');
             $.post(
                "ajax.php?action=checkUserEmail",
                {data:data},
                function(data){
                    if(data.error=='0'){     
                        var info = "";  
                    }else if(data.error=='1'){
                        var info = "<span style='color:#f00'>×"+data.msg+"</span>";  
                    } 
                    $("input[name='email']").next("span").html(info);
                },'json'
            );
        }else{
        	if(pattern_phone.test(data)){
        		alert("这是手机号！");
        	}else{
        		alert('请填写合法的邮箱或手机号！');
        	}
            var info = "<span style='color:#f00'>×邮箱格式不正确</span>"; 
            $("input[name='email']").next("span").html(info);
        }    
    })
})
</script>
</head>
<body>
<p><{$error}></p>
<form action="register.php" method="post" id="">
<table border='1'>
  <tr>
	<td>邮箱：</td>
	<td><input type="text" name="email" id="email"/></td>
	<td><div id="emailTip"></div></td>
  </tr>
  
 
 <!--  <tr>
	<td>验证码：</td>
	<td>
		<img style="cursor:pointer" src="include/codeimg.php" id="imgcode" onclick="document.getElementById('imgcode').src='include/codeimg.php?t='+Math.random()"  title="点击刷新"/>
		<input type="text" name="imgcode" id="imgcode"/>
	</td>
	<td><div id="imgcodeTip"></div></td>
  </tr> -->
  <tr>
  	<td colspan="3" align="center"><input type="submit" name="submit" value="提交"/></td>
  </tr>
</table>
</form>
</body>
</html>